package com.by.config;

import com.by.rule.MyRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//@RibbonClients(defaultConfiguration = MyRule.class) //全局设置负载规则，默认是轮询的
//@RibbonClient(name = "nacos-a", configuration = MyRule.class) //针对某个服务，特殊配置
public class RestConfig {
    @Bean
    public IRule rule(){

        //使用随机的策略
//        return new RandomRule();
        //指定使用Nacos提供的负载均衡策略
//        return new NacosRule();
        //自定义负载均衡策略
        return new MyRule();
    }
}
